import Vue from 'vue'
import store from './store'
import App from './App'
import {
	HttpWidget
} from '@/common/request/index.js'
import config from '@/common/request/config.js'
import parseHtml from '@/common/parseHtml.js'
import tools from '@/common/tools'
import uView from 'uview-ui';
Vue.use(uView);
import meRouter from '@/common/merouter'
// #ifdef H5
import wxApi from '@/common/wxApi'
// #endif
import api from '@/common/request/apis/index'
Vue.use(new HttpWidget())
import keyWords from "@/components/bian-keywords/index.vue"
Vue.component('key-words', keyWords)
// 考虑规范性,使用 module.exports 导出,应该使用 require 引用
let Chinese = require('./static/locales/zh-CHS.json')
let English = require('./static/locales/en.json')
let zhhk = require('./static/locales/zh-CHT.json') 
// VueI18n
import VueI18n from 'vue-i18n'
// VueI18n
Vue.use(VueI18n)
// VueI18n 
const i18n = new VueI18n({
	// 默认语言
	// locale: 'zh-CN',
	locale: 'zh-CN',
	// 引入语言文件
	messages: {
		'zh-CN': {message: Chinese},
		'en-US':{message: English}, 
	    'zh-HK': {message: zhhk}, 
	}
}) 
// VueI18n 
Vue.prototype._i18n = i18n
//新闻详情
const navToDetails = (id) => {
	let data = {
		id: id
	}
	uni.navigateTo({
		url: `/pages/news/details?data=${JSON.stringify(data)}`
	})
}
const msg = (title, duration = 3000, mask = false, icon = 'none') => {
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

const prePage = () => {
	uni.navigateBack();
}

Date.prototype.Format = function(fmt) {
	var o = {
		"M+": this.getMonth() + 1, //月份   
		"d+": this.getDate(), //日   
		"h+": this.getHours(), //小时   
		"m+": this.getMinutes(), //分   
		"s+": this.getSeconds(), //秒   
		"q+": Math.floor((this.getMonth() + 3) / 3), //季度   
		"S": this.getMilliseconds() //毫秒   
	};
	if (/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
}
// #ifdef H5  
console.log('h5--------')
import '@/common/back.js' 
Vue.prototype.$host = config.host;
// #endif
// #ifndef H5
Vue.prototype.$host = config.host;
// #endif
Vue.config.productionTip = false
Vue.prototype.$fire = new Vue();
Vue.prototype.$store = store;
Vue.prototype.$timer =[]; 
Vue.prototype.$api = {
	msg,
	prePage,
	navToDetails
};
Vue.prototype.$parseHtml = parseHtml
Vue.prototype.$tools = tools
Vue.prototype.$meRouter = meRouter
// #ifdef H5
Vue.prototype.$wxApi = wxApi
// #endif

App.mpType = 'app'

const app = new Vue({
	...App
})
app.$mount()
